﻿@{
    ViewBag.Title = "SaleOrder";
}
@section scripts
{   
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>  
    <script src="@Url.Content("~/Scripts/common/gridlayout.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
}
<body>
   <form id="form1" runat="server" method="post" style="height: 100%">
    
    @Html.Partial("~/Views/Modular/ReportsToolbar.cshtml")
    
    <div id = "DivHeader">
        <table style="margin-bottom:4px;">
            <tr>
                <td width ="70px" align="right">单据日期：</td>
                <td width ="310px">
                    @Html.Partial("~/Views/Modular/dxDateRange.cshtml") 
                </td>
                <td width ="70px" align="right">审核状态：</td>
                <td width ="150px">
                    <input id="comCheckFlag" name ="FCheckFlag" class="mini-combobox" style="width:150px;" 
                    showNullItem="false" required="true" allowInput="false" align="left" value="0" data ="dCheckFlag"/>  
                </td>
            </tr>
        </table>
        <table>
            <tr>
                <td width ="70px" align="right">客户名称：</td>
                <td width ="190px">    
                    @Html.Partial("~/Views/Modular/LookupCustInfo.cshtml")                       
                </td>
                <td width ="70px" align="right">门店名称：</td>
                <td width ="190px">    
                    @Html.Partial("~/Views/Modular/LookupStockInfo.cshtml")                      
                </td>
                <td width ="70px" align="right">单据类型：</td>
                <td width ="100px">
                    <input id="comBillType" name ="FBillType" class="mini-combobox" style="width:100px;" 
                    showNullItem="false" required="true" allowInput="false" align="left" data ="dBillType"/>                    
                </td>
            </tr>
        </table>
    </div>
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" borderStyle="border:1;" pageSize="15"
            url="../Report/GetCommonReport"
            allowCellSelect="true" allowCellEdit="true" showSummaryRow="true" ondrawsummarycell="onDrawSummaryCell"
            fitColumns="false" onrowdblclick="editBill" sortMode="client">
            <div property="columns">
                <div type="checkcolumn" ></div>    
                <div field="FDate1" width="110px"  headerAlign="center">起始日期</div> 
                <div field="FDate2" width="110px"  headerAlign="center">终止日期</div> 
                <div field="FNumber" width="110" headerAlign="center">商品编码</div>
                <div field="FName" width="200" headerAlign="center">商品名称</div>
                <div field="FSpec" width="100" headerAlign="center">商品规格</div>
                <div field="FUnitName" width="60" headerAlign="center">单位</div>
                <div field="FQty" name="FQty" width="100" headerAlign="center"align="right"numberFormat="#,0.00">数量</div>
                <div field="Amount" name="Amount" width="100" headerAlign="center"align="right"numberFormat="#,0.00">金额</div>
                <div field="avgPrice" name="avgPrice" width="100" headerAlign="center"align="right"numberFormat="#,0.00">平均单价</div>
                <div field="mCost" name="mCost" width="100" headerAlign="center"align="right"numberFormat="#,0.00">成本金额</div>
                <div field="Profit" name="Profit" width="100" headerAlign="center"align="right"numberFormat="#,0.00">毛利金额</div>
            </div>
        </div>  
    </div>
    
    <script type="text/javascript">

        var dBillType = [{ "id": "0", "text": "全部" },
                         { "id": "1", "text": "销售出库" },
                         { "id": "2", "text": "销售退货" }]

        var dCheckFlag = [{ "id": "0", "text": "全部" },
                         { "id": "1", "text": "未审核" },
                         { "id": "2", "text": "已审核" }]

        mini.parse();
        var form = new mini.Form("form1");
        var grid = mini.get("datagrid1");
        var uID = parent.window.getSystemAppID();
        var sumFields = "FQty,Amount,Profit,mCost";
        function FormShown() {
            var toDay = new Date();
            mini.getbyName("FDate1").setValue(toDay);
            mini.getbyName("FDate2").setValue(toDay);
            reset();
            LoadData();
        }

        function reset(){
            var nowDate = new Date();
            mini.getbyName("FDate1").setValue(nowDate);
            mini.getbyName("FDate2").setValue(nowDate);
            mini.getbyName("FCheckFlag").select(0);
            mini.getbyName("FBillType").select(0);
        }

        function clearloca() {
            mini.getbyName("FStockID").setValue("");
            mini.getbyName("FStockID").setText("");
            mini.getbyName("FStockName").setValue("");
            mini.getbyName("FCustItemID").setValue("");
            mini.getbyName("FCustItemID").setText("");
            mini.getbyName("FCustName").setValue("");
            reset();
        }

        function LoadData() {
            var cDate1 = mini.getbyName("FDate1").getFormValue();
            var cDate2 = mini.getbyName("FDate2").getFormValue();
            var mCheckFlag = mini.getbyName("FCheckFlag").getValue();
            var mBillType = mini.getbyName("FBillType").getValue();
            var mStockID = mini.getbyName("FStockID").getValue();
            var mCustItemID = mini.getbyName("FCustItemID").getValue();

            var json = "[{";
            json = json + '"mReportType":' + '"5001",';//列表类型
            json = json + '"mSystemAppID":' + '"' + uID + '",';
            json = json + '"mDate1":' + '"' + cDate1 + '",';
            json = json + '"mDate2":' + '"' + cDate2 + '",';
            json = json + '"mCheckFlag":' + '"' + mCheckFlag + '",';
            json = json + '"mBillType":' + '"' + mBillType + '",';
            json = json + '"mStockID":' + '"' + mStockID + '",';
            json = json + '"mObjectID":' + '"' + mCustItemID + '"';
            json = json + "}]";

            grid.load({ mydata: json });

            mExportDataUrl = grid.url;
            mExportDataJson = json;//导出
        }

        function printdata() {
            var url = "../Report/PrintReport";
            mini.open({
                url: url,
                title: "打印", width: 1000, height: 700,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var NoneDisplayCol = [0];
                    iframe.contentWindow.InitalPrint(grid, NoneDisplayCol, parent.window.getSystemCompany() + "销售商品汇总表");
                }
            });
        }

    </script>

    </form>
</body>